Skip to content

feat(vcs): surface detected VCS in arc which --json - #59

Merged
bfirestone merged 2 commits into
mainfrom
feat/vcs-in-arc-which
Jun 23, 2026
Merged

feat(vcs): surface detected VCS in arc which --json#59
bfirestone merged 2 commits into
mainfrom
feat/vcs-in-arc-which

Conversation

@bfirestone

Copy link
Copy Markdown
Contributor

Summary

Surfaces the detected version-control system(s) in arc which, so agents and skills can ask "am I in git, jj, or a colocated repo?" without spawning their own probes. Arc already detects git/jj internally (PR #58) for project resolution — this exposes it.

  • New vcs.Detect(dir) []string — pure filesystem walk (no git/jj binary), reports systems in stable git-first order via the existing gitfs.FindGitEntry / jjfs.FindJJEntry primitives.
  • arc which --json gains a vcs array, always present ([] when none, never null). Existing keys (project_id, source, project_name, warning) unchanged — the inline map[string]string became a typed whichResult struct.
  • Human-readable which gains a VCS: line (omitted when none detected).
$ arc which --json
{ ..., "vcs": ["git", "jj"] }     # colocated
                "vcs": ["jj"]     # native jj
                "vcs": ["git"]    # plain git
                "vcs": []         # neither

Design

Approved design: docs/plans/2026-06-23-vcs-in-arc-which.md. Surface decision was hybrid — extend arc which now (smallest, fits its orientation purpose); defer a dedicated arc vcs command until a skill needs remote/main_repo exposed (YAGNI, additive/non-breaking).

Tests

internal/vcs/vcs_test.go covers all four cases with real fixtures (git init + real .jj dirs): plain-git, native-jj, colocated, and neither (with an explicit non-nil assertion so JSON stays []). Verified end-to-end: colocated repo → ["git","jj"] in both JSON and human output.

gofmt, golangci-lint, and go test ./internal/vcs/... ./cmd/arc/... all clean. Pre-existing macOS-only symlink test failures in internal/api/internal/gitfs (tracked in arc-0ek8.08g0rw) are unaffected — identical at the base commit; CI (Linux) is green.

Closes arc-0ek8.05nd2z.

Add `vcs.Detect` helper that walks the filesystem (no binary invocations)
to identify git and/or jj repos in stable order. Wire it into `arc which`
via a typed `whichResult` struct so the `vcs` field (always present, never
null) appears in JSON output and a `VCS:` line appears in human-readable
output when a system is detected.
The which --json output gained a `vcs` array field, which breaks the two
integration tests that unmarshaled the output into map[string]string
(arrays can't decode into string values). Switch both to typed structs:
TestWhichJsonOutput now also asserts vcs is present as a non-null array;
TestWhichFromSymlinkAndRealPath decodes only the project_id it compares.
@bfirestone
bfirestone merged commit d54b1c7 into main Jun 23, 2026
3 checks passed
@bfirestone
bfirestone deleted the feat/vcs-in-arc-which branch June 23, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant